<template>
  <div id="app">
    <router-view />
  </div>
</template>

<script>
export default {
  name: "App",
  watch: {
    $route(to, from) {
      //监听路由是否变化
      alert(1);
      let token = Vue.cookie.get("token");
      if (!token || !/\S/.test(token)) {
        Vue.cookie.delete("token");
        next({ name: "login" });
      }
      next();
    },
  },
};
</script>

<style>
#app {
  font-family: "Avenir", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #2c3e50;
  margin-top: 60px;
  margin: 0 auto;
  width: 70%;
}
</style>
